package vmcs.boundary;

import java.awt.Panel;

/**
 * Title:        VMCS
 * Description:
 * Copyright:    Copyright (c) 2001
 * Company:      ISS
 * @author Pang Pingli
 * @version 1.0
 */

 import java.awt.*;
 import java.awt.event.*;

public class LabelledDisplay extends Panel {

  /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
public final static      int   DEFAULT = 5;
  public final static      char  FLOW = 'a';
  public final static      char   GRID = 'b';


  private  TextField             value;
  private  Label                 lb;

  public LabelledDisplay(String label, int length, char layout){

    if(layout == FLOW)
      this.setLayout(new FlowLayout(FlowLayout.CENTER));
    else
      if(layout == GRID)
        this.setLayout(new GridLayout(1,2));

    lb = new Label(label);
    System.out.println("LabelledDisplay:" + label);
    lb.setAlignment(Label.RIGHT);
    Panel  tp = new Panel();
    tp.setLayout(new FlowLayout());
    value = new TextField();
    //value.setBackground(Color.blue);
    value.setColumns(length);
    //tp.setBackground(Color.darkGray);

    tp.add(value);

    this.add(lb);
    this.add(tp);
   // this.setBackground(Color.darkGray);
  }

  public void addListener(ActionListener listener){

    value.addActionListener(listener);
  }

  public void setEditable(boolean v){
    value.setEditable(v);
    if(v == false){
      value.setBackground(Color.blue);
    }
  }
  public void  setValue(String  vl){
    value.setText(vl);
  }

  public void setValue(int vl){
    String   svl;

    svl = String.valueOf(vl);

    value.setText(svl);
  }

   public void setEchoChar(char c){
    value.setEchoChar(c);
  }

  public void setActive(boolean st){
    //System.out.println("LabelledDisplay.setActive:" + st);
    value.setEnabled(st);
    lb.setEnabled(st);
    value.setEditable(st);
  }

  public void setTextBackground(Color c){
    value.setBackground(c);
  }

  public void setTextForeground(Color c){
    value.setForeground(c);
  }

}